Skip to content

Conversation

@ncamera
Copy link
Collaborator

@ncamera ncamera commented Sep 15, 2025

Changes we propose in this PR

  • The CLI implementation for mercury has been moved to the @genexus/mercury-cli package (which uses the @genexus/mercury-build under the hood).

  • The @genexus/mercury package now only contains the core implementation for Mercury (CSS, fonts, icons, and some JavaScript).

  • Now, when running the mercury command of the CLI, the icons and fonts are generated under the node_modules/.genexus/mercury/assets/ folder. In other words, the mercury command generated the following content:

    • node_modules/.genexus/mercury/assets/css --> contains the CSS bundles to use in the dev server and dist build.
    • node_modules/.genexus/mercury/assets/fonts --> contains the fonts to use in the dev server and dist build.
    • node_modules/.genexus/mercury/assets/icons --> contains the icons to use in the dev server and dist build.

Tip

This change helps monorepo user experience fewer conflicts when multiple packages use different versions of Mercury, because now the Mercury assets will always be in the same folder (node_modules/.genexus/mercury/assets) and will be relative to the package that executes the mercury binary, regardless of the Mercury versions used in the monorepo.

  • Added the @genexus/vite-plugin-mercury package to facilitate configuration in Vite-based environments. This package contains a Vite plugin which:

    • Removes the need to copy the Mercury assets for the dev server and dist build. You can safely delete all copy tasks for the Mercury assets.

      // vite.config.ts
      import { defineConfig } from "vite";
      import { mercury } from "@genexus/vite-plugin-mercury";
      
      // https://vite.dev/config/
      export default defineConfig({
        plugins: [
      -   viteStaticCopy({
      -     targets: [
      -       {
      -         src: "{{ CSS outDir path }}",
      -         dest: "{{ CSS bundles final path }}"
      -       },
      -       {
      -         src: "<path to node_modules>/@genexus/mercury/dist/assets/fonts",
      -         dest: "{{ Fonts final path }}"
      -       },
      -       {
      -         src: "<path to node_modules>/@genexus/mercury/dist/assets/icons",
      -         dest: "{{ Icons final path }}"
      -       }
      -     ]
      -   })
      +   mercury({
      +     // (Optional)
      +     assetsPaths: {
      +       // Path where the CSS files of Mercury are located in the distribution build.
      +       cssPath: "{{ CSS bundles final path }}", // Defaults to "/assets/css/"
      +
      +       // Path where the font files of Mercury are located in the distribution build.
      +       fontsPath: "{{ Fonts final path }}", // Defaults to "/assets/fonts/"
      +
      +       // Path where the icon files of Mercury are located in the distribution build.
      +       iconsPath: "{{ Icons final path }}" // Defaults to "/assets/icons/"
      +     },
      +
      +     // More options...
      +   })
        ]
      });
    • The base/base.css bundle in now automatically inlined in the index.html, so you don't need to load it.

    • The bundle hashes are now automatically applied in the index.html, so you can safely remove the following:

      - import { setBundleMapping } from "@genexus/mercury/bundles.js";
      - import { bundleToHashMappings } from "./assets/mercury-css/bundle-to-hash-mappings";
      
      - // Establishes the mapping between bundle names and their generated hashes.
      - // For example, it maps the `components/button` bundle name to `button-e261832acea09e81.css`
      - setBundleMapping(bundleToHashMappings);
  • The installation guide for Angular, NextJS, React, and StencilJS has been simplified.

⚠️ Breaking changes

  • Now, the CLI is no longer included when installing @genexus/mercury. You must install the @genexus/mercury-cli package to use the Mercury CLI.

  • The CLI's outDir flag has been removed. Now, the generated CSS bundles will always be located in the node_modules/.genexus/mercury/assets/css folder (this node_modules is always generated in the same directory where the mercury binary is executed).

  • Changed the following default paths when using the Mercury CLI:

    Before After
    Fonts "./assets/fonts/" "/assets/fonts/"
    Icons "./assets/icons/" "/assets/icons/"
  • Removed the alternative way ("Using already generated CSS bundles") of using the CSS from the docs, as this unwanted feature limited the possibilities of the build process and the CLI.

  • The bundle-to-hash-mappings.ts file is now located in the ./node_modules/.genexus/mercury/bundle-to-hash-mappings.ts path.

This will help us to avoid issues when the Mercury dependency is duplicated. Also, this help us to set this mapping inline in the HTML.
This plugin replaces the need for using the CLI in Vite environments.
Also, inline the base/base bundle by default and preload the base/icons bundle by default.
Also, fix default values for mercuryOptions
@ncamera ncamera added feature Feature implementation pull request mercury Changes related to Mercury design system performance Work related to imporving the performance in the Design System target: minor This PR is targeted for the next minor release labels Sep 15, 2025
@ncamera ncamera marked this pull request as draft September 15, 2025 02:51
…li and vite-mercury-plugin packages

Now, @genexus/mercury only contains the core of Mercury, and we have packages for bulding Mercury, using it through out a CLI, and a plugin to work with Vite.

Breaking changes:
 - The default path for the fonts is now "/assets/fonts/" instead of "./assets/fonts/"

 - The default path for the icons is now "/assets/icons/" instead of "./assets/icons/"
@ncamera ncamera changed the title [mercury] Add the viteMercury plugin for Vite environments [mercury] The Mercury implementation is divided into the @genexus/mercury-build and @genexus/mercury-cli packages. Additionally, the @genexus/vite-plugin-mercury package has been added to facilitate configuration in Vite-based environments Nov 5, 2025
@ncamera ncamera added the documentation Improvements or additions to documentation label Nov 6, 2025
Comment on lines +174 to +185
needs: check-version
if: needs.check-version.outputs.mercury-build-changed == 'true'
uses: ./.github/workflows/install-and-deploy.yml
with:
node-version: "22.x"
cache: false
common-tests: false
publish: true
package: "packages/mercury-build"
secrets: inherit

publish-mercury-cli:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 10 days ago

To address the issue, you should add a permissions block specifying the minimal required privileges for the workflow. The best practice is to add this block at the root of the workflow file, so that all jobs inherit it unless they explicitly override it. If your jobs only need to read source files and pull packages, contents: read is usually safe and minimal. If jobs need to publish to npm/GitHub Packages, consider adding packages: write. For workflows that only need to check versions and publish, the most conservative permissions would be contents: read, but if you know that publishing jobs require write access to packages or contents, you can increase the permission for just those jobs as needed.

In this case, adding the following at the top level (just below name: but above on:), is the best fix:

permissions:
  contents: read

If you know that jobs which do publishing need to write to the packages, you may additionally grant packages: write – but since you can only change what you see, and the minimal fix is to add a contents: read block at the workflow level.

File/Region to change:

  • Edit .github/workflows/npmpublish.yml
  • Add the following after line 1 (name: Node.js Package), before on:

Suggested changeset 1
.github/workflows/npmpublish.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml
--- a/.github/workflows/npmpublish.yml
+++ b/.github/workflows/npmpublish.yml
@@ -1,7 +1,8 @@
 name: Node.js Package
+permissions:
+  contents: read
 
 on:
-  push:
     tags:
       - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
 
EOF
@@ -1,7 +1,8 @@
name: Node.js Package
permissions:
contents: read

on:
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +211 to +219
if: needs.check-version.outputs.vite-plugin-mercury-changed == 'true'
uses: ./.github/workflows/install-and-deploy.yml
with:
node-version: "22.x"
cache: false
common-tests: false
publish: true
package: "packages/mercury-plugins/vite-plugin-mercury"
secrets: inherit

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 10 days ago

To fix this, add an explicit permissions: block at the top-level of the workflow file, setting sensible defaults such as contents: read. This restricts the default permissions for all jobs to read-only, unless a job or workflow requires more. If specific jobs need different permissions, a permissions: block can be added at the job level, overriding the global setting. Since the install-and-deploy workflow is called using uses:, we should ensure those jobs get enough permission (most npm publish workflows only require contents: read to read code, but if you are creating GitHub releases you might need packages: write, contents: write, etc.), but from the content provided, adding a top-level block for least privilege is sufficient.

Add the following block just below name: Node.js Package, e.g. before or after on:, but the official GH docs recommend after name and before on::

permissions:
  contents: read

If, later, you determine that more permissions are needed per job, you can override at the job level, but for now this is minimal and sufficient.

Suggested changeset 1
.github/workflows/npmpublish.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml
--- a/.github/workflows/npmpublish.yml
+++ b/.github/workflows/npmpublish.yml
@@ -1,4 +1,6 @@
 name: Node.js Package
+permissions:
+  contents: read
 
 on:
   push:
EOF
@@ -1,4 +1,6 @@
name: Node.js Package
permissions:
contents: read

on:
push:
Copilot is powered by AI and may make mistakes. Always verify output.
@ncamera ncamera marked this pull request as ready for review November 6, 2025 15:45
@ncamera ncamera merged commit 49ba432 into main Nov 6, 2025
9 checks passed
@ncamera ncamera deleted the feat/vite-plugin branch November 6, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking changes dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation feature Feature implementation pull request mercury Changes related to Mercury design system performance Work related to imporving the performance in the Design System target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants